﻿using System;
using System.Web.UI;
using System.Collections.ObjectModel;
using Highcharts.Core;
using Highcharts.Core.Data.Chart;
using Highcharts.Core.PlotOptions;

namespace DemoWebforms
{
    public partial class Sample03 : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Exemplo03();
        }

        private void Exemplo03()
        {
            //título
            hcTemperatura.Title = new Title("Consumo de energia");
            
            //definições de eixos
            hcTemperatura.YAxis.Add(new YAxisItem { title = new Title("Kw/hora") });
            hcTemperatura.XAxis.Add(new XAxisItem
                                        {
                                            categories = new object[] { "domingo", "segunda", "terça", "quarta", "quinta", "sexta", "sábado" }
                                        });

            //dados
            var series = new Collection<Serie>
                {
                    new Serie {name = "geladeira", data = new object[] {10, 11, 12, 10, 9, 7, 9}},
                    new Serie {name = "televisão", data = new object[] {4, 6, 7, 7, 8, 13, 11}}
                };

            //opção para empilhar os gráficos
            hcTemperatura.PlotOptions = new PlotOptionsAreaSpline { stacking = Stacking.normal, fillOpacity = 0.3 };
            
            //customização de tooltip
            hcTemperatura.Tooltip = new ToolTip("this.x +': '+ this.y +' Kw/hora'");

            //customização de legenda
            hcTemperatura.Legend = new Legend { layout = Layout.vertical, 
                                                borderWidth = 3, 
                                                align = Align.right,
                                                y = 20,
                                                x = -20,
                                                verticalAlign = VerticalAlign.top,
                                                shadow = true,
                                                backgroundColor = "#e3e6be"
                                              };

            //bind do controle
            hcTemperatura.DataSource = series;
            hcTemperatura.DataBind();
        }
    }
}